<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui.js"></script>
</head>
<body>

<%--不解析的搜索框--%>
<script type="text/html" id="toolbar">
    <!-- 1 显示搜索表单 -->
    <div class="layui-inline">
        <form action="" class="layui-form">
            <div class="layui-input-inline">
                <input type="text" name="search" id="search" class="layui-input">
            </div>
            <div class="layui-input-inline">
                <button onclick="handleSearch()" type="button" class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-search"> </i></button>
            </div>
        </form>

    </div>
</script>


<table id="logTable" lay-filter="logTable"></table>
<%--动态生成表格--%>
<script>
    layui.use("table",function(){
        var table = layui.table;
        table.render({
            elem:"#logTable",
            cols:[[
                {field:"logId",title:"日志编号",sort:true},
                {field:"username",title:"用户名"},
                {field:"operation",title:"操作"},
                {field:"description",title:"操作描述"},
                {field:"requestMethod",title:"请求方法名"},
                {field:"requestParam",title:"请求参数表"},
                {field:"timeMillion",title:"执行耗时"},
                {field:"ipAddress",title:"用户ip"},
                {field:"createDate",title:"操作时间"}
            ]],
            url:"${pageContext.request.contextPath}/bzLog/showAll",
            page:true,//开启分页
            limits:[5,10,12,20],//每页条数的选择项
            limit:5//每页显示的条数，默认：10
            ,toolbar:"#toolbar"
        });
    })
</script>



<%--为查询按钮添加功能--%>
<script type="text/javascript">
    function handleSearch(){
        layui.use("table",function(){
            var table = layui.table;
            var $=layui.jquery;
            var search = $("#search").val();
            //2 根据条件重新加载表格
            table.reload("logTable",{
                url:"${pageContext.request.contextPath}/bzLog/showAll",
                where:{
                    "search":search
                }
            })
        })
    }
</script>



</body>
</html>